package com.ruoyi.basic.service.impl;

import com.ruoyi.basic.domain.Show;
import com.ruoyi.basic.mapper.ShowMapper;
import com.ruoyi.basic.service.ShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.ArrayList;
import java.util.List;

@Service("showService")
public class ShowServiceImpl implements ShowService {
    @Autowired
    private ShowMapper showMapper;

    class SearchResult {
        List<Show> shows;
        String  deptId;

        public List<Show> getShows() {
            return shows;
        }

        public void setShows(List<Show> shows) {
            this.shows = shows;
        }

        public String getDeptId() {
            return deptId;
        }

        public void setDeptId(String deptId) {
            this.deptId = deptId;
        }
    }

    class ToWeb{}

    class ReturnResult{
        ArrayList resultList = new ArrayList();
        public void addResultList(Object result) {
            resultList.add(result);
        }
        public ArrayList getResultList(){
            return resultList;
        }
    }

//    @Override
//    @Transactional
    @Override
    public ArrayList findRecordList(Show show){
//        System.out.println("999");
        String startTime = show.getStartTime();
        String endTime = show.getEndTime();
        List<String> deptIds = show.getDeptIds();
        List<Show> shows = null;
        ArrayList<SearchResult> resultList = new ArrayList();
        ArrayList<SearchResult> resultList1 = new ArrayList();
        for (String deptId:deptIds)
        {
            SearchResult result = new SearchResult();
//            shows = showMapper.findRecordList(startTime,endTime,deptId);
            result.setShows(showMapper.findRecordList(startTime,endTime,deptId));
            result.setDeptId(deptId);
            resultList.add(result);
//            -------------------------
            SearchResult result1 = new SearchResult();
            result1.setShows(showMapper.findRecordList1(startTime,endTime,deptId));
            result1.setDeptId(deptId);
            resultList1.add(result1);
        }
        ArrayList<ArrayList<SearchResult>> arr = new ArrayList();
        arr.add(resultList);
        arr.add(resultList1);
        return arr;
    }


    @Override
    public List<Show> findAllRecordList(Show show){
//        System.out.println("999");
        String startTime = show.getStartTime();
        String endTime = show.getEndTime();
//        showMapper.findRecordList(startTime,endTime)
//        ArrayList<ArrayList<SearchResult>> arr = new ArrayList();
        SearchResult result = new SearchResult();
        ArrayList<SearchResult> resultList = new ArrayList();
        result.setShows(showMapper.findAllRecordList(startTime,endTime));
        resultList.add(result);
        ArrayList<ArrayList<SearchResult>> arr = new ArrayList();
        arr.add(resultList);
//        List<Show> shows = showMapper.findAllRecordList(startTime,endTime);
//        List<Show> shows1 = showMapper.findAllRecordList(startTime,endTime);
        return showMapper.findAllRecordList(startTime,endTime);
    }
}
